function createPixel(){ //debugger; var img = document.createElement("img"); img.src = "//traffic.outbrain.com/network/trackpxl?advid=52574&action=view"; document.body.appendChild(img); var img3 = document.createElement("img"); img3.src = "//trc.taboola.com/conversionsminds-top5-sc/log/3/action?name=Click_out&item-url="+encodeURIComponent(window.location.href); img3.style.width="0px"; img3.style.height="0px"; document.body.appendChild(img3); var img4 = document.createElement("img"); img4.src = "//bat.bing.com/action/0?ti=5296455&Ver=2"; img4.style.width="0px"; img4.style.height="0px"; document.body.appendChild(img4); } (function($) { var element = $('.follow-scroll'), originalY = element.offset().top; // Space between element and top of screen (when scrolling) var topMargin = 20; // Should probably be set in CSS; but here just for emphasis element.css('position', 'relative'); $(window).on('scroll', function(event) { var scrollTop = $(window).scrollTop(); element.stop(false, false).animate({ top: scrollTop < originalY ? 0 : scrollTop - originalY + topMargin }, 300); }); })(jQuery);